//
//  TestTableViewCell.swift
//  iOSProject-XX
//
//  Created by LeeXu on 2020/7/17.
//
import Alamofire

typealias successHandler = (_ result: AnyObject?) -> Void
typealias failureHandler = (_ error: Error?) -> Void

class AppRequestAPI {
    /**
     *  封装基础请求参数
     */
    static func getRequestParams(_ params: Parameters?) -> Parameters {
        var baseParams:Parameters = ["ver": kAppVersion]
        if params != nil {
            baseParams.updateValue(params!, forKey: "params")
        }
        return baseParams
    }
    
    /**
     *  接口基础请求方法
     */
    static func baseRequest(_ url:String , instance: AppBaseRequest!, params: Parameters?, deserializeClass: AppBaseModel.Type!, successHandler: @escaping (_ result: AnyObject?) -> Void, failureHandler: @escaping (_ error: Error?) -> Void) {
//        let requestParmas = AppRequestAPI.getRequestParams(params)
        instance.request(url, params: params, deserializeClass: deserializeClass, successHandler: successHandler, failureHandler: failureHandler)
    }
    
//    // MARK: - 以下此App相关业务接口
    static func requestBanner(successHandler:@escaping successHandler,failureHandler:@escaping failureHandler) {
        let api = AppBaseRequest()
        AppRequestAPI.baseRequest(AppConstants.API.HomePage, instance: api, params: nil , deserializeClass: BannerDataModel.self, successHandler: successHandler, failureHandler: failureHandler)
    }
    
}
